package com.thiswhyme.demo.msgpush.core.config;

import com.thiswhyme.demo.msgpush.core.WsConstant;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;

/**
 * @description: 消息推送配置属性
 * @author: thiswhyme
 * @date: 2021/9/30
 */
@Data
@ConfigurationProperties(prefix = "msg-push.websocket")
public class MsgPushProperties {

    /**
     * 实现方式：支持NIO，WS两种方式
     */
    private String impl = WsConstant.IMPL_WS;

    /**
     * ws实现方式配置，impl=WS时有效
     */
    private WsProperties wsProperties;

    /**
     * nio实现方式配置，impl=NIO时有效
     */
    private NioProperties nioProperties;

    @Data
    public static class WsProperties {

        /**
         * WebSocket Path
         */
        private String path = "/websocket";
    }

    @Data
    public static class NioProperties {

        /**
         * WebSocket Path
         */
        private String path = "/websocket";

        /**
         * netty服务port
         */
        private int port = 8081;

        /**
         * 数据最大聚合大小
         */
        private int maxContentLength = 65536;

        /**
         * 心跳间隔
         */
        private int heartbeat = 5;
    }
}
